﻿import QtQuick 2.0
import QtQuick.Controls 1.3
import QtQuick.Controls.Styles 1.3
import QtQuick.Layouts 1.1
Rectangle {
    id: protectionPopUp
    width: 412
    height: 283 + colInfo.height + 12  //+ desc.height
    radius: 3
//    color: "#88000000"
    transform: Scale { origin.x: 0; origin.y: 0; xScale: root.x_enl-0.3;yScale: root.y_enl-0.4}
    color:app.getSystemThemeColor()
    visible: false
    property int mapX
    property int mapY
    property string u_id: ""
    property var vido_url
    property var image_url
    property alias u_check: check.checked
    property alias m_check: check_2.checked
     property alias v_check: check_vido.checked
    // 0 为什么都没有 1 为视频 2 为图片
    property int vOri: 0
    MouseArea{
        anchors.fill: parent
    }

    Item{
        anchors.top: parent.top
        anchors.left: parent.left
        anchors.right: parent.right
        anchors.topMargin: 7
        anchors.leftMargin: 12
        anchors.rightMargin: 12
        width: parent.width - anchors.leftMargin - anchors.rightMargin
        APPCloseMenu{
            anchors.top: parent.top
            anchors.right: parent.right
            onClose:{
                protectionPopUp.visible = false
            }
        }

        Text{
            id: title
            width: parent.width
            height: 30
            color: "#FFFFFF"
            font.pixelSize: 20
            anchors.top: parent.top
            anchors.topMargin: 20
            horizontalAlignment : Text.AlignHCenter
            font.family: "黑体"
        }
        Rectangle{
            id: separator
            width: parent.width
            height: 1
            color: "#FFF"
            anchors.top: title.bottom
        }

        Image{
            id: imgInfo
            anchors.top: separator.bottom
            anchors.topMargin: 8
            width: parent.width
            height: 195
        }

        Column{
            id: colInfo
            anchors.top: imgInfo.bottom
            anchors.topMargin: 8
            spacing: 4
            width: parent.width
            //位置
            Item{
                width: parent.width
                height: 34 +(locInfo.lineCount-1) *14
                Rectangle{
                    id: locTitle
//                    width: 88
                    width: 110
                    height: parent.height
                    color: "#40D114"
                    Text{
                        text: "地理位置："
                        width: parent.width
                        height: parent.height
                        horizontalAlignment: Text.AlignHCenter
                        verticalAlignment: Text.AlignVCenter
                        font.family: "黑体"
                        font.pixelSize: 16

                    }
                }

                Rectangle{
                    width: parent.width - 110
                    height: parent.height
                    color: "#FFF"
                    anchors.left: locTitle.right
                    Text{
                        id: locInfo
                        width: parent.width
                        height: parent.height
                        anchors.left: parent.left
                        anchors.leftMargin: 5
                        color: "#000"
                        verticalAlignment: Text.AlignVCenter
                        font.family: "黑体"
                        font.pixelSize: 16
//                        maximumLineCount: 1
                       wrapMode: Text.WrapAnywhere
                    }
                }

            }
            //面积
            Item{
                width: parent.width
                height: 34
                Rectangle{
                    id: areaTitle
//                    width: 88
                    width: 110
                    height: parent.height
                    color: "#40D114"
                    Text{
                        text: "区域面积："
                        width: parent.width
                        height: parent.height
                        horizontalAlignment: Text.AlignHCenter
                        verticalAlignment: Text.AlignVCenter
                        font.family: "黑体"
                        font.pixelSize: 16
                    }
                }

                Rectangle{
                    width: parent.width - 110
                    height: parent.height
                    color: "#FFF"
                    anchors.left: areaTitle.right
                    Text{
                        id: areaInfo
                        width: parent.width
                        height: parent.height
                        anchors.left: parent.left
                        anchors.leftMargin: 5
                        color: "#000"
                        verticalAlignment: Text.AlignVCenter
                        font.family: "黑体"
                        font.pixelSize: 16
                    }
                }
            }

//            //核心区 coreAreaInfo
//            Item{
//                width: parent.width
//                height: 24
//                Rectangle{
//                    id: coreAreaTitle
//                    width: 100
//                    height: parent.height
//                    color: "#40D114"
//                    Text{
//                        text: "核心区："
//                        width: parent.width
//                        height: parent.height
//                        horizontalAlignment: Text.AlignHCenter
//                        verticalAlignment: Text.AlignVCenter
//                        font.family: "黑体"
//                        font.pixelSize: 14
//                    }
//                }

//                Rectangle{
//                    width: parent.width - 100
//                    height: parent.height
//                    color: "#FFF"
//                    anchors.left: coreAreaTitle.right
//                    Text{
//                        id: coreAreaInfo
//                        width: parent.width
//                        height: parent.height
//                        anchors.left: parent.left
//                        anchors.leftMargin: 5
//                        color: "#000"
//                        verticalAlignment: Text.AlignVCenter
//                        font.family: "黑体"
//                        font.pixelSize: 14
//                    }
//                }
//            }

//            //缓冲区 bufferInfo
//            Item{
//                width: parent.width
//                height: 24
//                Rectangle{
//                    id: bufferTitle
//                    width: 100
//                    height: parent.height
//                    color: "#40D114"
//                    Text{
//                        text: "缓冲区："
//                        width: parent.width
//                        height: parent.height
//                        horizontalAlignment: Text.AlignHCenter
//                        verticalAlignment: Text.AlignVCenter
//                        font.family: "黑体"
//                        font.pixelSize: 14
//                    }
//                }

//                Rectangle{
//                    width: parent.width - 100
//                    height: parent.height
//                    color: "#FFF"
//                    anchors.left: bufferTitle.right
//                    Text{
//                        id: bufferInfo
//                        width: parent.width
//                        height: parent.height
//                        anchors.left: parent.left
//                        anchors.leftMargin: 5
//                        color: "#000"
//                        verticalAlignment: Text.AlignVCenter
//                        font.family: "黑体"
//                        font.pixelSize: 14
//                    }
//                }
//            }

//            //实验区 experimentalAreaInfo
//            Item{
//                width: parent.width
//                height: 24
//                Rectangle{
//                    id: experimentalAreaTitle
//                    width: 100
//                    height: parent.height
//                    color: "#40D114"
//                    Text{
//                        text: "实验区："
//                        width: parent.width
//                        height: parent.height
//                        horizontalAlignment: Text.AlignHCenter
//                        verticalAlignment: Text.AlignVCenter
//                        font.family: "黑体"
//                        font.pixelSize: 14
//                    }
//                }

//                Rectangle{
//                    width: parent.width - 100
//                    height: parent.height
//                    color: "#FFF"
//                    anchors.left: experimentalAreaTitle.right
//                    Text{
//                        id: experimentalAreaInfo
//                        width: parent.width
//                        height: parent.height
//                        anchors.left: parent.left
//                        anchors.leftMargin: 5
//                        color: "#000"
//                        verticalAlignment: Text.AlignVCenter
//                        font.family: "黑体"
//                        font.pixelSize: 14
//                    }
//                }
//            }

            //主要保护对象 protectionInfo
            Item{
                width: parent.width
                height: 34 +(protectionInfo.lineCount-1) *14
                Rectangle{
                    id: protectionTitle
                    width: 110
                    height: parent.height
                    color: "#40D114"
                    Text{
                        text: "主要保护对象："
                        width: parent.width
                        height: parent.height
                        horizontalAlignment: Text.AlignHCenter
                        verticalAlignment: Text.AlignVCenter
                        font.family: "黑体"
                        font.pixelSize: 15
                    }
                }

                Rectangle{
                    width: parent.width - 110
                    height: parent.height
                    color: "#FFF"
                    anchors.left: protectionTitle.right
                    Text{
                        id: protectionInfo
                        width: parent.width
                        height: parent.height
                        anchors.left: parent.left
                        anchors.leftMargin: 5
                        color: "#000"
                        verticalAlignment: Text.AlignVCenter
                        font.family: "黑体"
                        font.pixelSize: 16
//                        maximumLineCount: 1
                       wrapMode: Text.WrapAnywhere
                    }
                }
            }


            //类型 typesInfo
            Item{
                width: parent.width
                height: 34
                Rectangle{
                    id: typesTitle
                    width: 110
                    height: parent.height
                    color: "#40D114"
                    Text{
                        text: "类型："
                        width: parent.width
                        height: parent.height
                        horizontalAlignment: Text.AlignHCenter
                        verticalAlignment: Text.AlignVCenter
                        font.family: "黑体"
                        font.pixelSize: 16
                    }
                }

                Rectangle{
                    width: parent.width - 110
                    height: parent.height
                    color: "#FFF"
                    anchors.left: typesTitle.right
                    Text{
                        id: typesInfo
                        width: parent.width
                        height: parent.height
                        anchors.left: parent.left
                        anchors.leftMargin: 5
                        color: "#000"
                        verticalAlignment: Text.AlignVCenter
                        font.family: "黑体"
                        font.pixelSize: 16
                    }
                }
            }


            //级别 levelInfo
            Item{
                width: parent.width
                height: 34
                Rectangle{
                    id: levelTitle
                    width: 110
                    height: parent.height
                    color: "#40D114"
                    Text{
                        text: "级别："
                        width: parent.width
                        height: parent.height
                        horizontalAlignment: Text.AlignHCenter
                        verticalAlignment: Text.AlignVCenter
                        font.family: "黑体"
                        font.pixelSize: 16
                    }
                }

                Rectangle{
                    width: parent.width - 110
                    height: parent.height
                    color: "#FFF"
                    anchors.left: levelTitle.right
                    Text{
                        id: levelInfo
                        width: parent.width
                        height: parent.height
                        anchors.left: parent.left
                        anchors.leftMargin: 5
                        color: "#000"
                        verticalAlignment: Text.AlignVCenter
                        font.family: "黑体"
                        font.pixelSize: 16
                    }
                }
            }


            //时间
            Item{
                width: parent.width
                height: 34
                Rectangle{
                    id: timeTitle
                    width: 110
                    height: parent.height
                    color: "#40D114"
                    Text{
                        text: "建成时间："
                        width: parent.width
                        height: parent.height
                        horizontalAlignment: Text.AlignHCenter
                        verticalAlignment: Text.AlignVCenter
                        font.family: "黑体"
                        font.pixelSize: 16
                    }
                }

                Rectangle{
                    width: parent.width - 110
                    height: parent.height
                    color: "#FFF"
                    anchors.left: timeTitle.right
                    Text{
                        id: timeInfo
                        width: parent.width
                        height: parent.height
                        anchors.left: parent.left
                        anchors.leftMargin: 5
                        color: "#000"
                        verticalAlignment: Text.AlignVCenter
                        font.family: "黑体"
                        font.pixelSize: 16
                    }
                }
            }


            //隶属部门 departmentInfo
//            Item{
//                width: parent.width
//                height: 34
//                Rectangle{
//                    id: departmentTitle
//                    width: 110
//                    height: parent.height
//                    color: "#40D114"
//                    Text{
//                        text: "隶属部门："
//                        width: parent.width
//                        height: parent.height
//                        horizontalAlignment: Text.AlignHCenter
//                        verticalAlignment: Text.AlignVCenter
//                        font.family: "黑体"
//                        font.pixelSize: 16
//                    }
//                }

//                Rectangle{
//                    width: parent.width - 110
//                    height: parent.height
//                    color: "#FFF"
//                    anchors.left: departmentTitle.right
//                    Text{
//                        id: departmentInfo
//                        width: parent.width
//                        height: parent.height
//                        anchors.left: parent.left
//                        anchors.leftMargin: 5
//                        color: "#000"
//                        verticalAlignment: Text.AlignVCenter
//                        font.family: "黑体"
//                        font.pixelSize: 16
//                    }
//                }
//            }

            //视频展示
            Item{
                width: parent.width
                height: 34
                Rectangle{
                    id: videodisplayTitle
                    width: 110
                    height: parent.height
                    color: "#40D114"
                    Text{
                        text: "信息展示："
                        width: parent.width
                        height: parent.height
                        horizontalAlignment: Text.AlignHCenter
                        verticalAlignment: Text.AlignVCenter
                        font.family: "黑体"
                        font.pixelSize: 16
                    }
                }

                Rectangle{
                    width: parent.width - 110
                    height: parent.height
                    color: "#FFF"
                    anchors.left: videodisplayTitle.right
                    CheckBox{
                        id: check
                        checked: false
                        visible: false
                        anchors.left: parent.left
                        anchors.leftMargin: 5
                        anchors.verticalCenter: parent.verticalCenter
                        style: CheckBoxStyle{
                            indicator: Rectangle {
                                            implicitWidth: 14
                                            implicitHeight: 14
                                            radius: 3
                                            border.color: control.activeFocus ? "darkblue" : "gray"
                                            border.width: 1
                                            Rectangle {
                                                visible: control.checked
                                                color: "#555"
                                                border.color: "#333"
                                                radius: 1
                                                anchors.margins: 4
                                                anchors.fill: parent
                                            }
                                    }
                        }
                        onCheckedChanged:
                        {
                            videoImageItem.visible = check.checked

                            videoImageItem.setUrl(image_url,title.text)
                        }
                    }

                    Text{
                        id:test_image
                        text: "图片"
                        visible: false
//                        width: parent.width
//                        height: parent.height
                        anchors.left: check.right
                        anchors.leftMargin: 3
                        anchors.verticalCenter: check.verticalCenter
                        font.family: "黑体"
                        font.pixelSize: 16
                    }

                    CheckBox{
                        id: check_vido
                        checked: false
                        visible: false
                        anchors.left: test_image.right
                        anchors.leftMargin: 9
                        anchors.verticalCenter: parent.verticalCenter
                        style: CheckBoxStyle{
                            indicator: Rectangle {
                                            implicitWidth: 14
                                            implicitHeight: 14
                                            radius: 3
                                            border.color: control.activeFocus ? "darkblue" : "gray"
                                            border.width: 1
                                            Rectangle {
                                                visible: control.checked
                                                color: "#555"
                                                border.color: "#333"
                                                radius: 1
                                                anchors.margins: 4
                                                anchors.fill: parent
                                            }
                                    }
                        }
                        onCheckedChanged:
                        {
                            videoItem.visible = checked
                            videoItem.setUrl(vido_url,title.text)

                            if(videoItem.visible===false)
                            {
                               videoItem.clear()
                            }
                        }
                    }

                    Text{
                        id:test_video
                        text: "视频"
                        visible: false
//                        width: parent.width
//                        height: parent.height
                        anchors.left: check_vido.right
                        anchors.leftMargin: 5
                        anchors.verticalCenter: check_vido.verticalCenter
                        font.family: "黑体"
                        font.pixelSize: 16
                    }
                }
            }

            //绿盾整改
            Item{
                width: parent.width
                height: 34
                Rectangle{
                    id: greenShieldTitle
                    width: 110
                    height: parent.height
                    color: "#40D114"
                    Text{
                        text: "绿盾整改："
                        width: parent.width
                        height: parent.height
                        horizontalAlignment: Text.AlignHCenter
                        verticalAlignment: Text.AlignVCenter
                        font.family: "黑体"
                        font.pixelSize: 16
                    }
                }

                Rectangle{
                    width: parent.width - 110
                    height: parent.height
                    color: "#FFF"
                    anchors.left: greenShieldTitle.right
                    CheckBox{
                        id: check_1
                        checked: false
                        visible: true
                        anchors.left: parent.left
                        anchors.leftMargin: 5
                        anchors.verticalCenter: parent.verticalCenter
                        style: CheckBoxStyle{
                            indicator: Rectangle {
                                            implicitWidth: 14
                                            implicitHeight: 14
                                            radius: 3
                                            border.color: control.activeFocus ? "darkblue" : "gray"
                                            border.width: 1
                                            Rectangle {
                                                visible: control.checked
                                                color: "#555"
                                                border.color: "#333"
                                                radius: 1
                                                anchors.margins: 4
                                                anchors.fill: parent
                                            }
                                    }
                        }
                        onCheckedChanged:
                        {
                            app.slotShowGreenShield(check_1.checked,u_id)
                        }
                    }

                }
            }


            //基本信息
            Item{
                width: parent.width
                height: 34
                Rectangle{
                    id: gEssentialnforTitle
                    width: 110
                    height: parent.height
                    color: "#40D114"
                    Text{
                        text: "基本情况："
                        width: parent.width
                        height: parent.height
                        horizontalAlignment: Text.AlignHCenter
                        verticalAlignment: Text.AlignVCenter
                        font.family: "黑体"
                        font.pixelSize: 16
                    }
                }

                Rectangle{
                    width: parent.width - 110
                    height: parent.height
                    color: "#FFF"
                    anchors.left: gEssentialnforTitle.right
                    CheckBox{
                        id: check_2
                        checked: false
                        visible: true
                        anchors.left: parent.left
                        anchors.leftMargin: 5
                        anchors.verticalCenter: parent.verticalCenter
                        style: CheckBoxStyle{
                            indicator: Rectangle {
                                            implicitWidth: 14
                                            implicitHeight: 14
                                            radius: 3
                                            border.color: control.activeFocus ? "darkblue" : "gray"
                                            border.width: 1
                                            Rectangle {
                                                visible: control.checked
                                                color: "#555"
                                                border.color: "#333"
                                                radius: 1
                                                anchors.margins: 4
                                                anchors.fill: parent
                                            }
                                    }
                        }
                        onCheckedChanged:
                        {

                            remarksItem.visible = checked
                            remarksItem.upData(u_id,title.text)
//                            app.slotShowGreenShield(check_1.checked,u_id)
                        }
                    }

                }
            }

        }

//        Rectangle{
//            id: desc
//            width: parent.width
//            anchors.top: colInfo.bottom
//            anchors.topMargin: 4
//            color: "#FFF"
//            height: descInfo.implicitHeight + 10
//            Text{
//                id: descInfo
//                anchors.fill: parent
//                anchors.margins: 5
//                width: parent.width - 10
//                wrapMode: Text.Wrap
//                color: "#000"
//                font.family: "黑体"
//                font.pixelSize: 14
//            }
//        }

    }


    Connections
    {
        target:app
        onSignalShowProtectionInfo:
        {
            u_id =  ""
            vido_url = ""
            image_url = ""
            vOri = 0
            check_1.checked =false
            check.checked = false
            raning.visible = false
            protectionPopUp.visible = true;
            title.text = vMap.name;
            locInfo.text = vMap.loc;
            areaInfo.text = vMap.area +"公顷";
            timeInfo.text = vMap.time;
//            descInfo.text = vMap.desc;
            imgInfo.source = "../image/protectionArea/" + vMap.image;
            protectionPopUp.mapX = vMap.x;

            protectionInfo.text = vMap.protection //主要保护对象
            typesInfo.text = vMap.type //类型
            levelInfo.text = vMap.level //级别
//            departmentInfo.text = vMap.department //隶属部门
            u_id=vMap.id

            var z = app.slotGetNPAShowInfo(u_id)
            if(z.length>0)
            {
                var t_o= JSON.parse(z)

                if(t_o.video.length>0)
                {

                    test_video.visible = true
                    check_vido.visible =true

                    vido_url= t_o.video //视频地址
                    vido_url = "file:///" +vido_url
                }else
                {
                    test_video.visible = false
                    check_vido.visible =false

                }

                if(t_o.images.length>0)
                {
                    test_image.visible =true
                    check.visible =true

                    var i = t_o.images
                    var arr = i.split(';');
                    //检测是不是数组的实例
                    arr instanceof Array //true
                    for(var y=0; y<arr.length ;y++)
                    {
                        arr[y] = "file:///" +arr[y]
                    }
                    image_url = arr;
                }else
                {
                    test_image.visible =false
                    check.visible =false

                }
            }else
            {
                test_image.visible =false
                test_video.visible = false
                check_vido.visible =false
                check.visible =false
            }

//            property var vido_url
//            property var image_url
        }
    }
}

